﻿using CommandLine;

namespace MyOS.Utils
{
    public class CommandUtils
    {
        [Verb("touch", HelpText = "创建一个新文件")]
        public class CreateFileOptions
        {
            [Value(0, HelpText = "欲创建的文件")] public string NewFile { get; set; }

            [Option('o', "over-write", Default = false, Required = false, HelpText = "强制覆盖文件,默认不覆盖")]
            public bool Overwrite { get; set; }

            [Option('t', "target", Required = true, HelpText = "目标文件目录")]
            public string TargetDir { get; set; }

            [Option('s', "size", Required = true, HelpText = "文件大小")]
            public short FileSize { get; set; }
        }

        [Verb("cp", HelpText = "复制文件")]
        public class CopyFileOptions
        {
            [Value(0, HelpText = "源文件")] public string SourceFile { get; set; }

            [Option('o', "over-write", Required = false, HelpText = "(若目标目录存在同名文件)强制覆盖文件")]
            public bool Overwrite { get; set; }

            [Option('t', "target", Required = true, HelpText = "目标文件目录")]
            public string TargetDir { get; set; }
        }

        [Verb("rm", HelpText = "删除文件(夹)")]
        public class RemoveFileOption
        {
            [Value(0, HelpText = "欲删除的文件(夹)")] public string TargetFile { get; set; }

            [Option('f', "force", Default = false, Required = false, HelpText = "若文件夹内有文件则删除其下所有文件")]
            public bool ForceDelete { get; set; }

            [Option('t', "target", Required = true, HelpText = "欲将文件移动到的路径")]
            public string TargetDir { get; set; }

            [Option('t', "type", Required = true, HelpText = "目标文件类型,d为目录,e为文本文件")]
            public char TargetType { get; set; }
        }

        [Verb("mv", HelpText = "移动文件(夹)")]
        public class MoveFileOption
        {
            [Value(0, HelpText = "源文件")] public string SourceFile { get; set; }

            [Option('o', "over-write", Required = false, HelpText = "(若目标目录存在同名文件)强制覆盖文件")]
            public bool Overwrite { get; set; }

            [Option('t', "target", Required = true, HelpText = "目标文件目录")]
            public string TargetDir { get; set; }
        }

        [Verb("cat", HelpText = "打开文件")]
        public class OpenFileOption
        {
            [Value(0, HelpText = "源文件")] public string SourceFile { get; set; }
        }

        [Verb("vi", HelpText = "编辑文件")]
        public class EditFileOption
        {
            [Value(0, HelpText = "源文件")] public string SourceFile { get; set; }
        }

        [Verb("chmod", HelpText = "修改文件权限")]
        public class ChangePermissionOption
        {
            [Value(0, HelpText = "源文件")] public string SourceFile { get; set; }

            [Option('a', Required = true, HelpText = "文件权限，1 可读 2可写 3可读可写 0 不可读不可写")]
            public int FilePermission { get; set; }
        }

        [Verb("mke2fs", HelpText = "格式化磁盘")]
        public class FormatDiskOption
        {
            [Value(0, HelpText = "目标磁盘")] public char Diskname { get; set; }
        }

        [Verb("mkdir", HelpText = "建立目录")]
        public class MakeDirOption
        {
            [Value(0, HelpText = "目录名")] public string DirName { get; set; }
        }

        [Verb("chdir", HelpText = "改变当前目录")]
        public class ChangeDirOption
        {
            [Value(0, HelpText = "目标目录名")] public string DirName { get; set; }
        }
    }
}